<!DOCTYPE html>
<html lang='cn' xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>添加产品子类</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
    <meta content="" name="description"/>
    <meta content="" name="author"/>
    <link th:href="@{/backend/css/bootstrap.min.css}" href="../../../static/backend/css/bootstrap.min.css"
          rel="stylesheet" type="text/css"/>
    <link th:href="@{/backend/css/bootstrap-responsive.min.css}"
          href="../../../static/backend/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css"/>
    <link th:href="@{/backend/css/font-awesome.min.css}" href="../../../static/backend/css/font-awesome.min.css"
          rel="stylesheet" type="text/css"/>
    <link th:href="@{/backend/css/style-metro.css}" href="../../../static/backend/css/style-metro.css" rel="stylesheet"
          type="text/css"/>
    <link th:href="@{/backend/css/style.css}" href="../../../static/backend/css/style.css" rel="stylesheet"
          type="text/css"/>
    <link th:href="@{/backend/css/style-responsive.css}" href="../../../static/backend/css/style-responsive.css"
          rel="stylesheet" type="text/css"/>
    <link th:href="@{/backend/css/default.css}" href="../../../static/backend/css/default.css" rel="stylesheet"
          type="text/css" id="style_color"/>
    <link th:href="@{/backend/css/uniform.default.css}" href="../../../static/backend/css/uniform.default.css"
          rel="stylesheet" type="text/css"/>
    <link rel="shortcut icon" th:href="@{/backend/images/favicon.ico}"
          href="../../../static/backend/images/favicon.ico"/>
</head>

<body>
<div class="container-fluid">
    <div class="row-fluid">
        <h3 class="page-title"><i class="fa fa-object-group"></i> 分类管理</h3>
        <ul class="breadcrumb">
            <li>
                <a href="list.html"><i class="fa fa-home"></i>分类管理</a>
                <i class="fa fa-angle-right"></i>
            </li>
            <li>
                <a href="#">添加产品子类</a>
            </li>
        </ul>
    </div>
    <div class="row-fluid">
        <div class="portlet box light-blue">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-reorder"></i>
                    添加产品子类
                </div>
            </div>
            <div class="portlet-body">
                <form class="form-horizontal" action="#">
                    <div class="control-group">
                        <label class="control-label">产品子类Id：</label>
                        <div class="controls">
                            <input name="typeId" type="text" class="m-wrap media" placeholder="形如1318"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">产品子类名称：</label>
                        <div class="controls">
                            <input name="typeName" type="text" class="m-wrap media"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">所属产品大类：</label>
                        <div class="controls">
                            <select name="categoryId" class="small m-wrap">

                            </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">状态：</label>
                        <div class="controls">
                            <select name="state" class="small m-wrap small">
                                <option selected="selected" value="1000">生效</option>
                                <option value="1100">失效</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="button" onclick="add()" class="btn blue"><i class="fa fa-check"></i>确定</button>&emsp;
                        <button type="button" onclick="javascript:history.back();" class="btn"><i
                                class="fa fa-times"></i>返回
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<script th:src="@{/backend/js/jquery-1.10.1.min.js}" src="../../../static/backend/js/jquery-1.10.1.min.js"
        type="text/javascript"></script>
<script src="../../../static/frontend/layer/layer.js" th:src="@{/frontend/layer/layer.js}"></script>
<script th:src="@{/backend/js/jquery-migrate-1.2.1.min.js}" src="../../../static/backend/js/jquery-migrate-1.2.1.min.js"
        type="text/javascript"></script>
<!-- IMPORTANT! Load jquery-ui-1.10.1.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
<script th:src="@{/backend/js/jquery-ui-1.10.1.custom.min.js}"
        src="../../../static/backend/js/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
<script th:src="@{/backend/js/bootstrap.min.js}" src="../../../static/backend/js/bootstrap.min.js"
        type="text/javascript"></script>
<script th:src="@{/backend/js/jquery.slimscroll.min.js}" src="../../../static/backend/js/jquery.slimscroll.min.js"
        type="text/javascript"></script>
<script th:src="@{/backend/js/jquery.blockui.min.js}" src="../../../static/backend/js/jquery.blockui.min.js"
        type="text/javascript"></script>
<script th:src="@{/backend/js/jquery.cookie.min.js}" src="../../../static/backend/js/jquery.cookie.min.js"
        type="text/javascript"></script>
<script th:src="@{/backend/js/jquery.uniform.min.js}" src="../../../static/backend/js/jquery.uniform.min.js"
        type="text/javascript"></script>
<script th:src="@{/backend/js/app.js}" src="../../../static/backend/js/app.js" type="text/javascript"></script>
<script type="text/javascript">
    //			<![CDATA[
    $(function () {
        $.ajax({
            url: "/fleastreet/manager/category/list",
            type: "post",
            success: function (result) {
                if (result.code == 0) {
                    showData(result.data);
                } else {
                    layer.msg(result.msg);
                }
            }
        });
    });

    function showData(data) {
        var select = $("[name='categoryId']");
        select.html("");
        if (!data || !data.length > 0) {
            return;
        }
        for (var i = 0; i < data.length; i++) {
            var option = $("<option></option>");
            option.attr("value", data[i].categoryId);
            option.text(data[i].categoryName);
            select.append(option);
        }
    }

    function add() {

        if (!$("[name='typeName']").val()) {
            layer.msg("请输入分类名称！");
            return;
        }
        if (!$("[name='typeId']").val()) {
            layer.msg("请输入分类Id！");
            return;
        }
        if (!$("[name='categoryId']").val()) {
            layer.msg("请选择产品大类！");
            return;
        }
        $.ajax({
            cache: true,
            type: "POST",
            url: "/fleastreet/manager/category/type/add",
            data: $('.form-horizontal').serialize(),
            async: false,
            error: function (request) {
                layer.msg("Connection error");
            },
            success: function (result) {
                if (result.code == 0) {
                    layer.msg("创建成功！");
                    window.location.href = "/fleastreet/manager/category/type/list";
                } else {
                    layer.msg(result.msg);
                }
            }
        });
    }

    //		]]>
</script>
</body>

</html>


    